﻿namespace Digitalmes.WebApi.Middlewares;

/// <summary>
/// 全局异常处理中间件。
/// </summary>
public sealed class ErrorHandlerMiddleware(RequestDelegate next)
{
    public async Task Invoke(HttpContext httpContext)
    {
        if (!httpContext.User.Identity?.IsAuthenticated ?? false)
        {
            httpContext.Response.StatusCode = StatusCodes.Status401Unauthorized;
            return;
        }

        await next(httpContext);
    }
}
